<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<!--动态组件-->
		
		<div id="app">
		    <button v-for="item in tabs" @click="change = item.id">
		    	{{ item.text }}
		    </button>
		    <keep-alive>
		    	<component :is="change"></component>
		    </keep-alive>
		</div>
		
	</body>
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<script>
		new Vue({
		  el: '#app',
		  data: {
		  	change: 'one', // 默认显示组件 one
		    tabs: [
		    	{id: 'one', text: '线路一'},
		        {id: 'two', text: '线路二'},
		        {id: 'thr', text: '线路三'}
		    ]
		  },
		  components: {
		  	one: {template: '<div>我是线路一</div>'},
		    two: {template: '<div>我是线路二</div>'},
		    thr: {template: '<div>我是线路三</div>'}
		  }
		})
		
	</script>
</html>
